class Solution {
public:
    int missingNumber(vector<int>& nums) {
        /*int i = 0;
        for(; i < nums.size(); ++i)
        {
            if(nums[i] != i)
                break;
        }
        return i;*/
        int left = 0;
        int right = nums.size() - 1;
        int mid = 0;
        while (left <= right)
        {
            mid = left + (right - left) / 2;
            if (nums[mid] == mid)
                left = mid + 1;
            else
                right = mid - 1;
        }
        return left;
    }
};